﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;

namespace Firefly.Framework.Windows.Forms
{
    public class Form : MoveableControl
    {
        public Form()
            : base()
        {
        }

        protected override Point GetMinimumSize()
        {
            return new Point(Math.Max(WindowsService.Instance.Theme.Form.MinimumSize.X, MinimumSize.X),
                Math.Max(WindowsService.Instance.Theme.Form.MinimumSize.Y, MinimumSize.Y));
        }

        #region IDrawable Members

        public override void Draw(GameTime gameTime)
        {
            if (Visible)
            {
                if (Sizeable)
                {
                    WindowsService.Instance.Theme.Form.Draw("Sizeable", DrawRectangle, Color);
                }
                else
                {
                    WindowsService.Instance.Theme.Form.Draw("Default", DrawRectangle, Color);
                }

                Rectangle titleRectangle = new Rectangle(DrawRectangle.X + (int)TextOffset.X,
                    DrawRectangle.Y + (int)TextOffset.Y,
                    DrawRectangle.Width - (int)TextOffset.X - (int)TextOffset.Z,
                    DrawRectangle.Height - (int)TextOffset.Y - (int)TextOffset.W);
                WindowsService.Instance.Theme.Fonts[Font].Draw(Text, titleRectangle, FontSize, FontColor);
                DrawChildren(gameTime);
            }
        }

        #endregion
    }
}
